/*
 * This file is part of PDBEdit.
 * 
 * PDBEdit is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * PDBEdit is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with PDBEdit.  If not, see <http://www.gnu.org/licenses/>.
 *  
 * Creation date : 13/05/2011
 * Copyright (c) Guerfyld 2010. All rights reserved.
 * http://......
 */
package pdbfile;

/**
 * The PDBLinked class manage PilotDB Linked field
 *
 * @author guerfyld
 * @version 1.0
 */
public class PDBLinked extends PDBString {
	int column;
	int lnkColumn;

	/**
	 * Constructor
	 *
	 * @param val	pilotDB field raw value
	 */
	public PDBLinked(int col, int lnkCol) {
		super(null);
		column = col;
		lnkColumn = lnkCol;
	}

	public PDBLinked(String val) {
		super(val);
		column = 0;
		lnkColumn = 0;
	}

	/**
	 * Constructor
	 *
	 * @param stm	Stream to read
	 * @param pos	Start read position in stream
	 */
	public PDBLinked(PDBInputStream stm, long pos) throws Exception {
		super(stm.readStringZ(pos));
		column = 0;
		lnkColumn = 0;
	}

	/**
	 * Get column linked
	 *
	 * @return	
	 */
	public int getColumn() {
		return column;
	}

	/**
	 * Get link column
	 *
	 * @return	
	 */
	public int getLnkColumn() {
		return lnkColumn;
	}

	/**
	 * Clone object
	 * @return	New object
	 */
	public PDBType clone() {
		PDBLinked fld = new PDBLinked(strVal);
		return fld;
	}

	/**
	 * Write fields to stream
	 *
	 * &param stm	Stream to write
	 */
	public void write(PDBOutputStream stm) throws Exception {
		stm.writeString(getValue());
	}
}